/**
 * 虽然枚举类型(BasicOperationImpl) 不是可扩展的, 但是接口类型(IOperation)是可以扩展的;
 */
public enum BasicOperationImpl implements IOperation {
    PLUS("+") {
        @Override
        public double apply(double x, double y) {
            return x + y;
        }
    },
    MINUS("-") {
        @Override
        public double apply(double x, double y) {
            return x - y;
        }
    },
    TIMES("*"){
        @Override
        public double apply(double x, double y) {
            return x * y;

        }
    },
    DIVIDE("/"){
        @Override
        public double apply(double x, double y) {
            return x / y;
        }
    };


    // 运算符
    private final String symbol;

    BasicOperationImpl(String symbol) {
        this.symbol = symbol;
    }

    @Override
    public String toString() {
        return symbol;
    }
    }
